package com.shtel.custbehavior.service;


import com.shtel.custbehavior.entity.*;
import com.shtel.custbehavior.mapper.QueryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class CustbehaviorService {

    @Autowired
    QueryMapper queryMapper;

    //查询投诉信息
    public List<TousuInfo> querytousuinfo(String creditnum) {

        return queryMapper.querytousuinfo(creditnum);
    }

    //查询感知信息
    public List<FeelInfo> queryfeelinfo(String creditnum) {

        return queryMapper.queryfeelinfo(creditnum);
    }

    //查询接触轨迹
    public List<ContactInfo> querycontactinfo(String creditnum) {
        return queryMapper.querycontactinfo(creditnum);
    }

    //查询服务信息
    public List<ServiceInfo> queryserviceinfo(String creditnum) {
        return queryMapper.queryserviceinfo(creditnum);
    }

    //查询营销标签和推荐
    public List<LabelAndRecommend> querycustlabel(String creditnum) {
        List<LabelAndRecommend> labelAndRecommends = new ArrayList<>();
        List<CustLabel> custlabels = queryMapper.querycustlabel(creditnum);

        for (CustLabel custLabel : custlabels) {
            List<String> labels = new ArrayList<>();
            if (!(custLabel.getLabel() == null)) {

                labels.add(custLabel.getLabel());
            }
            if (!(custLabel.getLabel2() == null)) {

                labels.add(custLabel.getLabel2());
            }
            if (!(custLabel.getLabel3() == null)) {

                labels.add(custLabel.getLabel3());
            }
            LabelAndRecommend labelAndRecommend = new LabelAndRecommend();
            labelAndRecommend.setLabels(labels);
            labelAndRecommend.setRecommendationsale(custLabel.getRecommendationsale());
            labelAndRecommend.setRecommendationsentence(custLabel.getRecommendationsentence());
            labelAndRecommend.setRecommendationtaocan(custLabel.getRecommendationtaocan());
            labelAndRecommends.add(labelAndRecommend);
        }

//        LabelAndRecommend labelAndRecommend = new LabelAndRecommend();
//
//        List<String> labels = new ArrayList<>();
//        List<String> recommends = new ArrayList<>();
//        for(CustLabel custLabel:custlabels){
//
//            labels.add(custLabel.getLabel());
//            recommends.add(custLabel.getRecommendationsale());
//            recommends.add(custLabel.getRecommendationsentence());
//        }
//
//        labelAndRecommend.setLabels(labels);
//        labelAndRecommend.setRecommend("推荐十全十美套餐");

        return labelAndRecommends;

    }

}
